<template>
  <div class="main">
    <Header />
    <div class="operate">
      <ul class="tabs">
        <template v-for="(tab, index) in tabs" :key="index">
          <li @click="skipRoute(tab.route, index)" :class="[index===0?'first':'other',index==currentTabIndex?'checked':'']">{{ tab.name }}</li>
          <div v-if="index!==tabs.length-1" :class="['divider', (index === currentTabIndex|| index === currentTabIndex -1)?'hide':'']"></div>
        </template>
      </ul>
      <TimeQuery />
    </div>
    <router-view></router-view>
  </div>
</template>
<script setup>
import { defineProps, ref } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import Header from './Header.vue';
import TimeQuery from './TimeQuery.vue';
const props = defineProps({
  //页签列表
  tabs: {
    type: Array,
    default: () => []
  }
});
const router = useRouter();
const route = useRoute();
const path = route.path;
const index = props.tabs.map(item => item.route).indexOf(path);
const currentTabIndex = ref(index);
//路由切换
const skipRoute = (route, index) => {
  currentTabIndex.value = index;
  router.push(route);
};

</script>
<style scoped>
.main {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-image: url("@/assets/images/background.png");
  background-repeat: no-repeat;
  background-position: 100% 100%;
  background-size: 100% 100%;
}
.operate {
  height: 3.75rem;
  padding-top: 0.625rem;
  margin: 0 var(--hMargin);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(86, 211, 255, 0.4);
}

.tabs {
  list-style: none;
  color: rgba(255, 255, 255, 0.7);
  height: 3.125rem;
  font-size: 1.25rem;
  font-weight: 400;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  z-index: 2;
  margin: 0;
  padding: 0;
}

.tabs > .other {
  padding: 0 3.125rem;
  height: 3.125rem;
  line-height: 3.125rem;
  text-align: center;
  position: relative;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tabs > .other.checked:after {
  content: "";
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  /* background-color: #56d3ff; */
  background: linear-gradient(
    180deg,
    rgba(109, 147, 255, 0.8) 0%,
    rgba(40, 73, 166, 0.8) 49%,
    rgba(18, 49, 130, 0.8) 100%
  );
  transform: skewX(22.5deg);
  position: absolute;
  z-index: -1;
}
.tabs > .other.checked {
  color: #ffffff;
  text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);
  font-weight: bold;
}
.first {
  width: 12.5rem;
  height: 3.125rem;
  line-height: 3.125rem;
}
.tabs > li.checked.first {
  width: 12.5rem;
  height: 3.125rem;
  line-height: 3.125rem;
  background-image: url(../assets/images/tab_first.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.divider {
  width: 1px;
  height: 1.25rem;
  background: rgba(86, 211, 255, 0.3);
}

.divider.hide {
  background: transparent;
}
</style>
